<template>
	<view>
		<mc-framework navTitle="MES工控机" @changeLevel="changeLevel">

			<template #content>
				<view class="content" style="height: 100%;width: 100%;">
					<view class="contentBox">
						<view class="container">

							<uni-forms ref="baseForm" :modelValue="baseFormData">
								<view class="form-item-row">
									<uni-forms-item label="报工类型:" label-width="auto">
										<input v-model="baseFormData.Define1Name" type="text" placeholder="请选择报工类型"
											disabled />
										<text class="text" @click="addDefine1"></text>
									</uni-forms-item>
									<uni-forms-item label="生产日期:" label-width="auto">
										<input v-model="baseFormData.SCDate" disabled type="text"
											placeholder="请选择生产日期" />
										<text class="text" @click="Timeshow=true"></text>
									</uni-forms-item>
									<uni-forms-item label="工序:" label-width="auto">
										<input v-model="baseFormData.ProcedureName" disabled type="text"
											placeholder="请选择工序" />
										<text class="text" @click="addProcedurname"></text>
									</uni-forms-item>
									<uni-forms-item label="报工数量:" label-width="auto" required>
										<input v-model="baseFormData.FSumQty" disabled type="text"
											placeholder="自动带出报工数量" />
									</uni-forms-item>
									<uni-forms-item label="合格数量:" label-width="auto" required>
										<input v-model="baseFormData.FDailyQtt" type="text" placeholder="请输入合格数量"
											@input="addAmount('合格')" />
									</uni-forms-item>
									<uni-forms-item label="不合格数量:" label-width="auto">
										<input v-model="baseFormData.FNgQty" disabled type="text"
											placeholder="由不良报废自动带出" />
									</uni-forms-item>
									<uni-forms-item label="料废数量:" label-width="auto">
										<input disabled v-model="baseFormData.MaterialWaste" disabled type="text"
											placeholder="自动带出料废数量"></input>
									</uni-forms-item>
									<uni-forms-item label="工废数量:" label-width="auto">
										<input disabled v-model="baseFormData.IndustrialWaste" disabled type="text"
											placeholder="自动带出工废数量" />
									</uni-forms-item>
									<uni-forms-item label="生产人员:" label-width="auto">
										<input v-model="baseFormData.FProcessManName" type="text" disabled
											placeholder="自动带出生产人员" />
									</uni-forms-item>
									<uni-forms-item label="设备名称:" label-width="auto">
										<view class="input_container">
											<input v-model="baseFormData.EquipmentName" disabled type="text"
												placeholder="自动带出设备名称" />
											<u-icon name="close-circle" color="#2979ff" size="25"
												@click="closeEquipmentName"></u-icon>
										</view>
									</uni-forms-item>
									<uni-forms-item label="模具名称:" label-width="auto">
										<view class="uni_forms_item_view" @click="MoludNameclick">

											<text v-if="!baseFormData.MoludName"
												class="u_text">{{FormData.MoludName}}</text>
											<text v-else>{{baseFormData.MoludName}}</text>
										</view>
									</uni-forms-item>
									<uni-forms-item label="审核状态:" label-width="auto">
										<input v-model="baseFormData.ApproveName" type="text" placeholder="自动带出审核状态"
											disabled />
									</uni-forms-item>
									<uni-forms-item label="审核人:" label-width="auto">
										<input v-model="baseFormData.Approver" type="text" placeholder="自动带出审核人"
											disabled />
									</uni-forms-item>
									<uni-forms-item label="审核时间:" label-width="auto">
										<input v-model="baseFormData.ApproveTime" type="text" placeholder="自动带出审核时间" />
									</uni-forms-item>
									<!-- 下拉    如果计时   工时隐藏-->
									<uni-forms-item label="计件计时:" label-width="auto" required>
										<input v-model="baseFormData.PieceTime1" type="text" placeholder="请选择计时计件"
											disabled />
										<text class="text" @click="PieceTimeShow=true"></text>
									</uni-forms-item>
									<uni-forms-item label="工时:" label-width="auto"
										v-show="baseFormData.PieceTime1=='计时'">
										<input v-model="baseFormData.ManHour" type="text" placeholder="请输入工时" />
									</uni-forms-item>
								</view>
							</uni-forms>
						</view>
						<view class="table" style="width: 96%;text-align: center;margin: auto;">
							<table>
								<tr>

									<th width='15%'>派工单编号</th>
									<th width='40%'>产品名称</th>
									<th width='8%'>派工数量</th>
									<th width='8%'>完成数量</th>
									<th>可报工数量</th>
									<th>未审核报工数量</th>

								</tr>
								<tr>
									<td>
										<div class="newlineDiv"><text>{{baseFormData.PGBillNo}}</text></div>
									</td>

									<td>
										<view class="td_view">
											<div class="newlineDiv"><text>{{baseFormData.ProductName}}</text></div>

											<view class="SOPView">
												<u-button size="small" text="查看SOP" @click="addSOP"></u-button>
											</view>
										</view>

									</td>
									<td><input type="text" disabled v-model="baseFormData.FPlanQty"></input></td>
									<td><input type="text" disabled v-model="baseFormData.WCQty"></input></td>
									<td><input type="text" disabled v-model="baseFormData.ReportQty"></input></td>
									<td><input type="text" disabled v-model="baseFormData.NotApproveQty"></input></td>


								</tr>
							</table>

						</view>

					</view>
					<view class="bottomBtns2">
						<button class="button0" block @click="badnum">
							不良报废
						</button>
						<button class="button1" block @click='exception'>
							异常提交
						</button>
						<button class="button3" block @click="submit('保存')">
							报工提交
						</button>
						<button class="button2" block v-show='baseFormData.ApproveName=="未审核"' @click='toexamine'>
							审核
						</button>

					</view>

					<u-icon name="arrow-left" size="28" class="arrow_left" @click="rightshow=true"></u-icon>
					<!-- <u-icon name="arrow-right"></u-icon> -->


					<u-picker :show="JYJGshow" :columns="columns" @confirm="JYJGconfirm" @cancel='JYJGshow=false'
						@close='JYJGshow=false'></u-picker>
					<u-action-sheet :actions="Resultlist" :show="Resultshow" @select="ResultClick"
						@close="Resultshow=false"></u-action-sheet>


					<u-toast ref="uToast"></u-toast>


					<u-action-sheet :actions="MoludList" :show="MoludShow" @select="MoludClick"
						@close="MoludShow=false"></u-action-sheet>

					<u-action-sheet :actions="Define1List" :show="Define1Show" @select="Define1Click"
						@close="Define1Show=false"></u-action-sheet>

					<u-action-sheet :actions="PieceTimeList" :show="PieceTimeShow" @select="PieceTimeClick"
						@close="PieceTimeShow=false"></u-action-sheet>

					<u-action-sheet :actions="exceptionList" :show="exceptionShow" @select="exceptionClick"
						@close="exceptionShow=false"></u-action-sheet>

					<u-datetime-picker :show="Timeshow" v-model="value1" mode="date" @close="Timeshow = false"
						@cancel='Timeshow = false' @confirm='pickerConfirm'></u-datetime-picker>

					<u-action-sheet :actions="ProcedurnameList" :show="ProcedurnameShow" @select="ProcedurnameClick"
						@close="ProcedurnameShow=false"></u-action-sheet>
					<u-popup :show="rightshow" mode="right" @close="rightclose" @open="rightopen" :width="500"
						class="rightshowView" :safeAreaInsetTop='true'>
						<view class="table tableTow">
							<table>
								<tr>
									<th width='30%'>报工日期</th>
									<th>白夜班</th>
									<th>报工数</th>
									<th>良品数</th>
									<th>不良品数</th>
									<th>审核状态</th>
								</tr>
								<tbody>

									<tr v-for="(item,index) in DailyOutputList"
										@click="rightclose(item.FDailyOutputID)">
										<td>{{item.BillDate}}</td>
										<td>{{item.ShiftName}}</td>
										<td>{{item.FSumQty}}</td>
										<td>{{item.FDailyQtt}}</td>
										<td>{{item.FNgQty}}</td>
										<td>{{item.Approve?'已审核':'未审核'}}</td>

									</tr>

								</tbody>

							</table>

						</view>

					</u-popup>


					<u-popup :show="popup_logout" mode="center" :closeOnClickOverlay="false" :round="4">
						<view class="popup-content">
							<view class="popup-content_close x-c">
								<uni-icons type="closeempty" color="#999" size="20"
									@click='popup_logout = false'></uni-icons>
							</view>
							<view class="x-c title">
								<text>{{popuptitle}}</text>
							</view>
							<view class="contentView">
								<text>{{popupcontent}}</text>
							</view>
							<view class="btnBox x-ac">
								<!-- 	<u-button v-show="popuptitle!='报错'" type="info" :text="cancelText"
									@click='cancelClick'></u-button> -->
								<u-button type="primary" :text="confirmText" @click="confirmClick"></u-button>
							</view>
						</view>
					</u-popup>
				</view>
			</template>
		</mc-framework>
		<u-loading-page :loading="loadingPage" class="loading-page" :loading-text="loadingName"></u-loading-page>
	</view>
</template>

<script>
	const open = uni.requireNativePlugin("Html5App-openFile");
	import {
		getFormatDateTime,
		getBefore7DateTime
	} from '@/mes/common/base.js';
	export default {
		data() {
			return {
				loadingPage: false,
				loadingName: '',
				readOnlyShow: false,
				confirmText: '确认',
				cancelText: '取消',
				popuptitle: '',
				popupcontent: '',
				popup_logout: false,
				FormData: {
					MoludName: '请选择模具名称',
					EquipmentName: '请选择机台'
				},
				baseFormData: {
					FSumQty: '',
					FDailyQtt: '',
					FNgQty: '',
					PieceTime1: '',
					PieceTime: 0,
					obOrderID: 0,
					illNO: "0",
					illDate: ":",
					roductID: 0,
					roductName: "",
					eportQty: 0,
					PlanQty: 0,
					CQty: 0,
					DailyQtt: null,
					NGQty: 0,
					StateName: "",
					rocedureName: "",
					obPROCID: 0,
					JobDocTypeID: 0,
					Define1: '',
					Define1Name: '',
					TypeName: "",
					FProcessMan: '',
					FProcessManName: '',
					MaterialWaste: '',
					IndustrialWaste: '',
					FWorkshopID: 0,
					SCDate: '',
					ProcedureID: 0,
					WoOrderID: 0,
					EquipmentName: '',
					EquipmentID: 0,
					ShiftID: 0,

				},
				value1: Number(new Date()),
				Timeshow: false,
				sexs: [{
					text: '合格',
					value: 1
				}, {
					text: '不合格',
					value: 0
				}],
				tableData: [{
					name: '',
					QCEmplName: '',
					num: 3000

				}],
				routeIndex: 0,
				JYJGshow: false,
				columns: [
					['合格', '不合格']
				],
				JYJGshowIndex: 0,
				Resultshow: false,
				Resulttitle: '',
				Resultlist: [],

				PieceTimeShow: false,
				PieceTimeList: [{
						name: '计时',
						id: 1
					},
					{
						name: '计件',
						id: 0
					}
				],
				Define1Show: false,
				Define1List: [],
				someData: null,
				rightshow: false,
				JobPROCID: null,
				DailyOutputList: [],
				WasteList: [],
				exceptionShow: false,
				exceptionList: [{
						name: '设备异常',
						id: 0
					},
					{
						name: '模具异常',
						id: 1
					},
					{
						name: '工艺异常',
						id: 2
					},
				],
				MoludShow: false,
				MoludList: [],
				ProcedurnameShow: false,
				ProcedurnameList: []
			};
		},
		onShow() {
			this.getValue
			this.getList
		},
		onLoad(onload) {
			var that = this
			var item = JSON.parse(onload.item)
			this.getBadReasonList()
			if (item.FDailyOutputID) {
				that.queryList(item.FDailyOutputID)
			} else {
				delete item.FNGQty; // 删除obj对象的age属性
				console.log(item);
				this.baseFormData = item
				this.baseFormData.FProcessManName = this.baseFormData.FProcessManName ? this.baseFormData.FProcessManName :
					this
					.$store.state.UserInfo.UserName
				this.baseFormData.FProcessMan = this.baseFormData.FProcessMan ? this.baseFormData.FProcessMan : this.$store
					.state.UserInfo.EmplID

				this.baseFormData.EquipmentName = this.baseFormData.EquipmentName ? this.baseFormData.EquipmentName : this
					.$set(this.baseFormData, 'EquipmentName', this
						.$store.state.GuyueModule.MesBasicInfo.warehouse.EquipmentName)

				this.baseFormData.ShiftID = that.baseFormData.ShiftID ? that.baseFormData.ShiftID : this.$store.state
					.GuyueModule.MesBasicInfo.className.id
				this.baseFormData.EquipmentID = this.baseFormData.EquipmentID ? this.baseFormData.EquipmentID : this
					.$store.state.GuyueModule.MesBasicInfo.warehouse.EquipmentID
				this.baseFormData.SCDate = this.baseFormData.SCDate ? this.baseFormData.SCDate : getFormatDateTime(
					new Date())
				this.baseFormData.PieceTime1 = this.baseFormData.PieceTime1 ? this.baseFormData.PieceTime1 : '计件'
				this.baseFormData.PieceTime = this.baseFormData.PieceTime ? this.baseFormData.PieceTime : 0
				this.baseFormData.Define1Name = '报工单'
				this.baseFormData.Define1 = 3
			}

		},
		onBackPress(options) { // 监听页面返回
			if (options.from == 'navigateBack') { // 通过点击路由返回
				return false;
			} else if (options.from == 'backbutton') { // 通过外置返回
				return true;
			}
		},
		methods: {
			confirmClick() {
				let that = this;
				that.popup_logout = false
				// if (that.popupcontent == '确定审核吗？') {
				// 	that.submit('审核')
				// } else if (that.popuptitle == '通知') {
				// 	that.submit('退出')
				// }
			},
			getBadReasonList() {
				var that = this
				that.Request.request('getBadReasonList', {}, (ret) => {
					ret.data.ds.map(item => item.Qty = 0)

					that.WasteList = ret.data.ds

				})
			},
			getList() {

			},
			addAmount(str) {
				var that = this
				var num = that.baseFormData.FNgQty
				console.log(num);
				console.log(that.baseFormData.FDailyQtt);
				if (num == '' || num == undefined || num == null) {
					num = 0
				}
				that.baseFormData.FSumQty = Number(that.baseFormData.FDailyQtt) + Number(num)
				that.$forceUpdate()
			},


			// 工序
			ProcedurnameClick(e) {
				var that = this

				console.log(that.baseFormData);
				that.baseFormData = {
					...that.baseFormData,
					...e
				}
				this.baseFormData.MoludID = this.baseFormData.MoludID == null ? 0 : this.baseFormData.MoludID
				this.baseFormData.IsStart = ''

				that.$forceUpdate()
				console.log(that.baseFormData);
				that.ProcedurnameShow = false

			},
			addProcedurname() {
				var that = this;
				var obj = {
					EquipmentID: this.baseFormData.EquipmentID,
					IsStart: 1,
					JobOrderID: this.baseFormData.JobOrderID,
				}
				that.Request.request('getJobOrderPROC', obj, function(ret) {
					console.log(ret.data.ds);
					if (ret.status == 200 && ret.data.ds.length > 0) {
						ret.data.ds.map(item => item.name = item.ProcedureName)
						that.ProcedurnameList = ret.data.ds
						that.ProcedurnameShow = true
					}
				})
			},
			closeEquipmentName() {
				var that = this
				this.$set(this.baseFormData, 'EquipmentID', 0)
				this.$set(this.baseFormData, 'EquipmentName', '')
				this.$forceUpdate()
			},


			rightclose(id) {

				if (id) {
					this.queryList(id)
				}
				this.rightshow = false
			},
			rightopen() {

				var that = this
				var show = false
				if (that.baseFormData.JobPROCID) {
					show = true
				}
				if (show) {
					try {
						that.Request.request('getDailyOutputList', {
							JobPROCID: that.baseFormData.JobPROCID
						}, (ret) => {

							if (ret.status == 200) {
								that.DailyOutputList = ret.data.ds
							}
						})
					} catch (e) {
						console.log(e)
						this.$utils.hideLoading();
						this.$utils.msg('请求失败请重试')
					}
				}
			},
			getValue(WasteList, MaterialWasteList, IndustrialWasteList) {
				let that = this;
				console.log(MaterialWasteList);
				console.log(IndustrialWasteList);
				this.WasteList = WasteList
				this.MaterialWasteList = MaterialWasteList
				this.IndustrialWasteList = IndustrialWasteList
				var MaterialWaste = MaterialWasteList.reduce((sum, item) => sum + item.Qty, 0);
				var IndustrialWaste = IndustrialWasteList.reduce((sum, item) => sum + item.Qty, 0);

				this.$set(this.baseFormData, 'FNgQty', Number(MaterialWaste) + Number(IndustrialWaste))
				this.$set(this.baseFormData, 'IndustrialWaste', IndustrialWaste)
				this.$set(this.baseFormData, 'MaterialWaste', MaterialWaste)
				var num = that.baseFormData.FDailyQtt

				if (num == '' || num == undefined || num == null) {
					num = 0
				}

				this.$set(this.baseFormData, 'FSumQty', Number(num) + Number(that.baseFormData
					.FNgQty))
				this.$forceUpdate()
			},

			badnum() {
				let that = this;
				var url
				if (that.WasteList.length > 0) {
					url = `./defectivescrap?WasteList=${JSON.stringify(that.WasteList)}`
				} else {
					url = './defectivescrap'
				}
				uni.navigateTo({
					url: url,
					animationType: 'slide-in-right',
					animationDuration: 300
				});

			},
			pickerConfirm(e) {
				let that = this;
				var time = getFormatDateTime(e.value)
				this.baseFormData.SCDate = time
				this.Timeshow = false
				this.$forceUpdate()
			},
			addDefine1() {
				var that = this
				that.Define1Show = true
				that.Request.request('PGD_GetBGType', {}, (ret) => {
					console.log(ret.data);
					ret.data.ds.map(item => item.name = item.TypeName)
					that.Define1List = ret.data.ds
				})

			},

			addSOP() {
				var that = this
				try {
					that.Request.request('getProductSOP', {
						ProductID: that.baseFormData.ProductID
					}, (ret) => {
						console.log(ret.data);
						that.loadingName = '正在打开中…'
						that.loadingPage = true

						if (ret.status == 200) {
							if (ret.data.ds.length > 0) {
								var url = 'http://' + that.Request.serverIP() + ret.data.ds[0].FILEPATH
								console.log(url);
								uni.downloadFile({
									url: url,
									success: function(res) {
										if (res.tempFilePath) {
											var filePath = plus.io.convertLocalFileSystemURL(res
												.tempFilePath);
											console.log(JSON.stringify(filePath))
											open.openFile({
												filename: filePath,
												title: 'SOP查看',
												isShowBackIcon: true
											}, ret => {
												that.loadingPage = false
											});
										} else {
											that.changeshowToast()
										}

									}
								})
							} else {
								that.changeshowToast()
							}
						}
					})
				} catch (e) {
					console.log(e)
					this.$utils.hideLoading();
					this.$utils.msg('请求失败请重试')
				}
			},
			changeshowToast() {
				var that = this;
				that.loadingPage = false
				uni.showToast({
					title: '暂无此文档',
					icon: 'error',
					duration: 2000
				})
			},
			MoludNameclick() {
				var that = this
				that.Request.request('PGD_GetMolud', {
					ProductID: that.baseFormData.ProductID
				}, (ret) => {
					console.log(ret);
					console.log(ret.data.ds[0].status);
					if (ret.status == 200) {
						if (ret.data.ds[0].status == 500) {
							that.popuptitle = '报错'
							that.confirmText = '确认'
							that.cancelText = '取消'
							that.popupcontent = ret.data.ds[0].msg
							that.popup_logout = true

						} else {
							ret.data.ds.map(item => item.name = item.MoludCode)
							that.MoludList = ret.data.ds
							that.MoludShow = true
						}
					} else {
						that.confirmText = '确认'
						that.cancelText = '取消'
						that.popuptitle = '报错'

						that.popupcontent = ret.data.ds[0].msg
						that.popup_logout = true
					}
				})
			},
			MoludClick(e) {
				var that = this
				console.log(e);
				this.baseFormData.MoludName = e.name
				this.baseFormData.MoludID = e.MoludID
				this.MoludShow = false
				this.$forceUpdate()
			},
			Define1Click(e) {
				var that = this

				this.baseFormData.Define1Name = e.name
				this.baseFormData.Define1 = e.JobDocTypeID

				this.Define1Show = false
				this.$forceUpdate()
			},
			PieceTimeClick(e) {

				this.baseFormData.PieceTime1 = e.name
				this.baseFormData.PieceTime = e.id
				this.PieceTimeShow = false
				this.$forceUpdate()
			},

			ResultClick(e) {
				var that = this

				this.baseFormData.Result = e.ID
				this.baseFormData.ResultName = e.name
				that.Resultshow = false

				this.$forceUpdate()
			},
			exceptionClick(e) {
				var that = this
				console.log(e);
				console.log(this.baseFormData);
				that.exceptionShow = false
				var url
				let routes = getCurrentPages();
				let obj = {
					Name: '',
					APPFunID: '',
					length: routes.length
				}
				if (e.name == '设备异常') {
					obj.Name = '设备异常明细'
					obj.APPFunID = '设备异常明细'
					that.baseFormData.FaultTypeID = 1
				} else if (e.name == '模具异常') {
					obj.Name = '模具异常明细'
					obj.APPFunID = '模具异常明细'
					that.baseFormData.FaultTypeID = 2
				} else if (e.name == '工艺异常') {
					obj.Name = '工艺异常明细'
					obj.APPFunID = '工艺异常明细'
					that.baseFormData.FaultTypeID = 3
				}
				url = `../abnormal/exceptionDetails?obj=${JSON.stringify(that.baseFormData)}&titleName=${e.name}`
				let newData = JSON.parse(JSON.stringify(this.$store.state.GuyueModule.ModuleData_select));
				newData.push(obj);

				this.$store.commit('GuyueModule/ChangeAndSetStateData', {
					Name1: 'ModuleData_select',
					data: newData
				})
				uni.navigateTo({
					url: url,
					animationType: 'slide-in-right',
					animationDuration: 300
				});

				// this.$forceUpdate()
			},
			exception() {
				var that = this
				that.exceptionShow = true

			},
			changeResultshow() {
				var that = this
				that.Request.request('getJYResult', {
					FType: '首件检验'
				}, (ret) => {
					console.log(ret.data);
					if (ret.status == 200) {
						that.Resultlist = ret.data.ds
						that.Resultlist.map(item => {
							item.name = item.NAME
						})
						that.Resultshow = true
					}
				})

			},
			JYJGconfirm(e) {
				var name = e.value[0]
				var num
				this.JYJGshow = false
				if (name == '合格') {
					num = 1
				} else {
					num = 2
				}
				this.tableData[this.JYJGshowIndex].JYJG = num
				this.tableData[this.JYJGshowIndex].JYJGName = name

			},
			addJYJG(item, index) {
				this.JYJGshow = true
				this.JYJGshowIndex = index
			},
			toexamine() {
				var that = this
				this.submit('审核')
			},
			submit(str) {
				var that = this
				console.log(that.baseFormData);
				var show = true
				var msg

				if (that.baseFormData.FDailyQtt == '' || that.baseFormData.FDailyQtt == null) {
					show = false
					msg = '请输入合格数量'
				} else if (that.baseFormData.FSumQty == '' || that.baseFormData.FSumQty == null) {
					show = false
					msg = '请输入报工数量'
				} else if (!that.baseFormData.PieceTime1) {
					show = false
					msg = '请输入计时计件'
				}
				if (show) {

					that.Request.request('SelectFCJType', {}, (ret) => {
						console.log(ret.data);
						that.baseFormData.FCJType = ret.data.ds[0].FCJType

						that.baseFormData.MoludID = that.baseFormData.MoludID ? that.baseFormData.MoludID : 0
						that.baseFormData.FNgQty = that.baseFormData.FNgQty ? that.baseFormData.FNgQty : 0
						that.baseFormData.MaterialWaste = that.baseFormData.MaterialWaste ? that.baseFormData
							.MaterialWaste : 0
						that.baseFormData.IndustrialWaste = that.baseFormData.IndustrialWaste ? that
							.baseFormData.IndustrialWaste : 0
						console.log(that.baseFormData);
						that.baseFormData.ShiftID = that.baseFormData.ShiftID ? that.baseFormData.ShiftID : this
							.$store.state.GuyueModule.MesBasicInfo.className.id

						that.Request.request('savePGDDailyOutputBG', that.baseFormData, (ret) => {
							console.log(ret.data);
							if (ret.data.ds[0].status == 200) {
								var status
								that.$refs.uToast.show({
									title: '保存',
									type: 'success',
									message: '保存成功'
								})
								that.WasteList.map((item) => {
									if (item.Qty) {
										var obj = {
											FDailyOutputID: ret.data.ds[0].FDailyOutputID,
											FDailyOutputBadID: 0,
											BadReasonID: item.BadReasonID,
											Qty: item.Qty,
											ProcessType: item.ProcessType,
											ReasonName: item.ReasonName
										}

										that.Request.request('saveDailyOutputBadReason', obj,
											(ret) => {
												console.log(ret.data);
											})
									}
								})
								if (str == '审核') {
									that.Request.request('ApproveDailyOutput', {
										FDailyOutputID: that.baseFormData.FDailyOutputID
									}, (ret) => {
										console.log(ret.data);
										that.$refs.uToast.show({
											title: '审核',
											type: 'success',
											message: '审核成功'
										})
										setTimeout(() => {
											that.queryList(that.baseFormData
												.FDailyOutputID)
										}, 1000)
									})

								} else {
									setTimeout(() => {
										that.queryList(ret.data.ds[0].FDailyOutputID)
									}, 1000)
								}
							} else {
								that.confirmText = '确认'
								that.cancelText = '取消'
								that.popuptitle = '报错'
								that.popupcontent = ret.data.ds[0].msg
								that.popup_logout = true
							}
						})

					})

				} else {
					that.confirmText = '确认'
					that.cancelText = '取消'
					that.popuptitle = '报错'
					that.popupcontent = msg
					that.popup_logout = true
				}
			},
			changeLevel(data, row) {

				let routes = getCurrentPages(); //当前页面栈
				let backIndex = routes.length - row.length; // 计算返回页面栈数
				if (backIndex == 1) {
					let prevPage = routes[routes.length - 2]
					prevPage.$vm.getList()
				}
				uni.navigateBack({
					delta: backIndex
				})
			},

			queryList(id) {
				var that = this
				try {

					that.Request.request('getDailyOutputBGDetail', {
						FDailyOutputID: id
					}, (ret) => {
						console.log(ret.data);
						if (ret.status == 200) {

							that.baseFormData = ret.data.ds[0]
							that.baseFormData.ApproveTime = that.baseFormData.ApproveTime ? that.baseFormData
								.ApproveTime.replace('T', ' ') : ''
							that.$set(that.baseFormData, 'PGBillNo', ret.data.ds1[0].PGBillNo)
							that.$set(that.baseFormData, 'ProductID', ret.data.ds1[0].ProductID)
							that.$set(that.baseFormData, 'ProductName', ret.data.ds1[0].ProductName)
							that.$set(that.baseFormData, 'ReportQty', ret.data.ds1[0].ReportQty)
							that.$set(that.baseFormData, 'FPlanQty', ret.data.ds1[0].FPlanQty)
							that.$set(that.baseFormData, 'NotApproveQty', ret.data.ds1[0].NotApproveQty)
							that.$set(that.baseFormData, 'WCQty', ret.data.ds1[0].WCQty)
							that.$set(that.baseFormData, 'JobPROCID', ret.data.ds2[0].JobPROCID)
							that.$set(that.baseFormData, 'JobOrderID', ret.data.ds[0].JobOrderID)
							console.log(that.baseFormData);
							that.JobPROCID = ret.data.ds2[0].JobPROCID
							that.WasteList = ret.data.ds3
							that.$forceUpdate()
						}
					})
				} catch (e) {
					console.log(e)
					this.$utils.hideLoading();
					this.$utils.msg('请求失败请重试')
				}
			}

		}
	}
</script>

<style lang="scss">
	@import "../css/index.css";

	.rightshowView {
		width: 70vw !important;
	}

	.td_view {
		display: flex;
		align-items: center;
		border: none;


		.SOPView {
			flex: 1;
			box-sizing: border-box;

			.u-button {
				width: 10%;
				float: right;
				color: #fff;
				background-color: #51d0d0;
				box-sizing: border-box;
			}
		}
	}



	.bottomBtns2 {
		padding: 1%;
		position: fixed;
		bottom: 6vh;
		width: 100%;
		display: flex;

		button {
			display: inline-block;
			color: #fff;
			background-color: #51d0d0;
			width: 20%;
			font-size: 18px;
		}

		.button0 {
			background-color: #ffce04;
		}

		.button1 {
			background-color: red;
		}

		.button3 {
			width: 30%;
		}
	}

	.table table {
		table-layout: fixed;

		tr td {
			input {
				width: 100%;
				background-color: #e7e7e7 !important;

			}

			view {
				width: 100%;
				height: 100%;
				display: flex;
				justify-content: center;
				align-items: center;
				font-size: 10rpx;
			}
		}

	}

	.tableTow table {
		width: 70vw;

	}

	.arrow_left {
		position: fixed;
		bottom: 44.5%;
		right: 1px;
	}


	.input_container {
		display: flex;
		align-items: center;
		height: 100%;
		width: 20vw;
		float: right;

		input {
			flex: 1;
			height: 100%;
		}
	}
</style>